package com.szrt.javaweb.ch01.dyn;


import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.szrt.javaweb.ch01.dyn.aop.ActorDao;
import com.szrt.javaweb.ch01.dyn.aop.TransactionAspect;
import com.szrt.javaweb.ch01.dyn.aop.YmactorDaoImpl;


public class TYProxySpringTest {
	
	@Test
	public void testName() throws Exception {
		
		
		//YMActorDaoImpl ym = new YMActorDaoImpl();
		
		
		ClassPathXmlApplicationContext ioc = new ClassPathXmlApplicationContext("com/szrt/javaweb/ch01/dyn/applicationContext.xml");
		
		//TransactionAspect  aspect = new TransactionAspect();
		
		
		YmactorDaoImpl ym =(YmactorDaoImpl) ioc.getBean("ym");
		TransactionAspect  aspect = (TransactionAspect) ioc.getBean("transactionAspect");
		
		Object proxyObject = ProxyFactory.generateProxyObject(ym,aspect);
		
		System.out.println(proxyObject.getClass().getName());
		
		
		ActorDao ymProxy = (ActorDao) proxyObject;
		
		ymProxy.act();
		
		ioc.close();
	}
}
